package com.mccken.temp;

import java.util.ArrayList;
import java.util.List;

import com.mccken.temp.resource.PPTFile;
import com.mccken.temp.resource.PdfFile;
import com.mccken.temp.resource.ResourceFile;
import com.mccken.temp.resource.WordFile;
import com.mccken.temp.visitor.Compressor;
import com.mccken.temp.visitor.Extractor;
import com.mccken.temp.visitor.Visitor;

// 运行结果是：
// Extract PDF.
// Extract WORD.
// Extract PPT.
public class ToolApplication {
	public static void main(String[] args) {
		Visitor extractor = new Extractor();
		List<ResourceFile> resourceFiles = listAllResourceFiles(args[0]);
		for (ResourceFile resourceFile : resourceFiles) {
			resourceFile.accept(extractor);
		}

		Visitor compressor = new Compressor();
		for (ResourceFile resourceFile : resourceFiles) {
			resourceFile.accept(compressor);
		}
	}

	private static List listAllResourceFiles(String resourceDirectory) {
		List resourceFiles = new ArrayList<>();
		//...根据后缀(pdf/ppt/word)由工厂方法创建不同的类对象(PdfFile/PPTFile/WordFile) 
		resourceFiles.add(new PdfFile("a.pdf"));
		resourceFiles.add(new WordFile("b.word"));
		resourceFiles.add(new PPTFile("c.ppt"));
		return resourceFiles;
	}
}